<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class panel_model extends CI_Model {

	public function get_web_service()
	{
		$query = $this->db->get('web_service');
		return $query->result_array();
	}
	
	public function get_top_view()
	{
		$this->db->select('vdo_id ,vdo_name,vdo_view');
		$this->db->order_by('vdo_view' , 'desc');
		$query = $this->db->get('vdo' ,10);
		return $query->result_array();
	}

	public function like()
	{
		$this->db->where('like_rate' ,1);
		$this->db->select('like.vdo_id ,vdo_name');
		$this->db->join('vdo','vdo.vdo_id = like.vdo_id','left');
		$this->db->select_sum('like_rate');
		$this->db->group_by('like.vdo_id');
		$this->db->order_by('like_rate' ,'desc');
		$query = $this->db->get('like' ,10);
        return $query->result_array();
	}

	public function dislike()
	{
		$this->db->where('dislike_rate' ,1);
		$this->db->select('dislike.vdo_id ,vdo_name');
		$this->db->join('vdo','vdo.vdo_id = dislike.vdo_id','left');
		$this->db->select_sum('dislike_rate');
		$this->db->group_by('dislike.vdo_id');
		$this->db->order_by('dislike_rate' ,'desc');
		$query = $this->db->get('dislike' ,10);
        return $query->result_array();
	}


}